package joapp

// ------- appFlagCmdBase -------

type AppFlagCmdBase struct {
	name  string
	usage string
}

func (af *AppFlagCmdBase) Init(name, usage string) {
	af.name = name
	af.usage = usage
}

func (af *AppFlagCmdBase) GetName() string {
	return af.name
}

func (af *AppFlagCmdBase) GetUsage() string {
	return af.usage
}

// ------- appFlagBase -------

type IAppFlag interface {
	GetShortName() string
	GetLongName() string
	GetUsage() string
	Exist() bool
}

type AppFlagBase struct {
	AppFlagCmdBase
	longName string
	exist    bool
}

func (af *AppFlagBase) Init(shortName, longName, usage string) {
	if shortName == "" && longName == "" {
		panic("short name and long name can not both be empty")
	}

	lenShortName := len(shortName)
	if lenShortName > 0 && lenShortName != 1 {
		panic("length of short name more then 1")
	}

	af.AppFlagCmdBase.Init(shortName, usage)
	af.longName = longName
}

func (af *AppFlagBase) GetShortName() string {
	return af.name
}

func (af *AppFlagBase) GetLongName() string {
	return af.longName
}

func (af *AppFlagBase) Exist() bool {
	return af.exist
}
